<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

$headers = apache_request_headers();
if (!isset($headers['X-Requested-With']) || $headers['X-Requested-With'] != "XMLHttpRequest")
	die;

$news_id = UV::readInt($route->GET("news_id"));
$src = UV::readMQ($route->GET("src"));

if (!$db->getCell("select `news_id` from `news` where `news_id` = '$news_id' and `user_id` = '".$user->getUserId()."' limit 1"))
	die("0");

$path = MAIN_DIR.DS."files".DS."img".DS."news".DS."$news_id".DS;

if (is_dir($path."small"))
{
	$file = $path."small".DS.$src;
	if (is_file($file))
		unlink($file);
	else
		die("could'n find small img");
}
else
	die("could'n find small path");

if (is_dir($path."big"))
{
	$file = $path."big".DS.$src;
	if (is_file($file))
		unlink($file);
	else
		die("could'n find big img");
}
else
	die("could'n find big path");

echo 1;
?>
